package demo3;

public class Test {

    public static void main(String[] args) {
        try {
            int[] array = null;
            System.out.println(array.length);
            //System.out.println("hahaha......");
        }catch (Exception e) {
            e.printStackTrace();
            System.out.println("处理异常....");
        }
        System.out.println("程序继续执行.....");
    }

    public static void main4(String[] args) {
        try {
            int[] array = null;
            System.out.println(array.length);
            //System.out.println("hahaha......");
        }catch (ArithmeticException | NullPointerException e) {
            e.printStackTrace();
            System.out.println("处理异常....");
        }
        System.out.println("程序继续执行.....");
    }

    public static void main3(String[] args) {
        try {
            int[] array = null;
            System.out.println(array.length);
            //System.out.println("hahaha......");
        }catch (ArithmeticException e) {
            e.printStackTrace();
            System.out.println("处理ArithmeticException异常....");
        }catch (NullPointerException e) {
            e.printStackTrace();
            System.out.println("处理NullPointerException异常....");
        }
        System.out.println("程序继续执行.....");
    }
    public static void func(int[] array) throws Exception {
        if(array == null) {
            throw new Exception("传个参数看看..."+array);
        }
    }

    public static void main2(String[] args) {
        try {
            //存放可能出现异常的代码
            int[] array = null;
            func(array);
        }catch (Exception e) {
            System.out.println("捕获到了Exception异常！" +
                    "此时这里可以开始处理这个异常到了");
            //通过代码 直接发送邮件 -》短信 -》 打电话
            e.printStackTrace();
        }
        System.out.println("异常处理完 程序继续执行....");
    }

    public static void main1(String[] args) {
        int[] array = null;
        System.out.println(array.length);
        System.out.println("hahah");
    }
}